package com.itgungnir.diyshuo.http;

import com.itgungnir.diyshuo.bean.DiyBean;

import java.util.Map;

import rx.Scheduler;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by My on 2016/10/6.
 */

public class ListHelper {

    private static volatile ListHelper singleton;
    private ListHelper() {
    }

    public static ListHelper getInstance(){
        if (singleton==null){
            synchronized (ListHelper.class){
                if (singleton==null){
                    singleton=new ListHelper();
                }
            }
        }
        return singleton;
    }

    public void getListData(Map<String, String> params, Subscriber<DiyBean> subscriber){
        getListRetrofitService()
                .getData(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    public ListRetrofitService getListRetrofitService(){
        HttpHelper helper=HttpHelper.getInstance();
        return helper.getRetrofit().create(ListRetrofitService.class);
    }
}
